package br.com.felinelayer.client.clientSwing;

import br.com.felinelayer.common.Protocol;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;

/**
 *
 */
public class ButtonClient extends ComponentSwing<ButtonClient, JButton> implements ActionListener, br.com.felinelayer.client.IButtonClient {

    @Override
    protected void doInitialize() {
        jButton = initializeComponente( new JButton() );
        jButton.addActionListener( this );
    }
    private JButton jButton;

    @Override
    public ButtonClient setText( String text ) {
        jButton.setText( text );
        return this;
    }

    @Override
    public void actionPerformed( ActionEvent e ) {
        try {
            fireEvent( Protocol.EVENT_CLICK );
        } catch ( Exception ex ) {
            Logger.getLogger( ButtonClient.class.getName() ).log( Level.SEVERE, null, ex );
        }
    }

    @Override
    public String getText() {
        return jButton.getText();
    }
}
